import request from '@/utils/request'

export function getVerifyCode() {
  return process.env.BASE_API + '/auth/kaptcha?' + Math.random()
}

/**
 * @description 登陆
 * @param {Object} params
 */
export function login(params) {
  const data = {
    userName: params.username,
    password: params.password
  }
  const loginData = request({
    url: `login?params=${JSON.stringify(data)}`,
    method: 'post'
  })
  return loginData
}

export function getInfo() {
  return new Promise(function(resolve, reject) {
    resolve({
      message: '\u6210\u529f',
      data: {
        avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
        name: 'admin11',
        menus: []
      },
      resType: '200'
    })
  })
  // const data = {
  //   reqType: 'LIST'
  // }
  // return request({
  //   url: '/getMenu',
  //   method: 'post',
  //   data
  // })
}

export function logout() {
  // return new Promise(function(resolve, reject) {
  //   resolve({
  //     message: '\u7b7e\u540d\u8fc7\u671f',
  //     data: {
  //     },
  //     resType: '200'
  //   })
  // })
  return request({
    url: '/logout',
    method: 'post',
    data: {
      reqType: 'LOGOUT'
    }
  })
}

/**
 * @description 检测是否登陆
 * @param {*} params
 */
export function checkLogin() {
  const data = {}
  return request({
    url: '/logincheck',
    method: 'post',
    data
  })
}
